package com.example.cinemaorder.controller;

import com.example.cinemaorder.entity.vo.UpdateMovieSaleVo;
import com.example.cinemaorder.service.SysMovieService;
import com.example.cinemaorder.service.SysSessionService;
import com.example.cinemaorder.service.impl.SysSessionServiceImpl;
import com.example.cinemaorder.util.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;


@RestController
public class SysSessionController {

    @Autowired
    SysSessionService sysSessionService;

//    根据选中的排片信息，查询座位、影片等信息
    @GetMapping("/sysSession/find/{id}")
    public Object findSessionById(@PathVariable Long id) {
        return new ResponseResult(200,"查询座位信息成功",sysSessionService.findSessionById(id));
    }

//    查询电影海报
    @GetMapping("/sysSession/poster/{id}")
    public Object findPosterById(@PathVariable Long id){
        return new ResponseResult(200,"查询电影海报成功",sysSessionService.findPosterByid(id));
    }

//    查询电影类别
    @GetMapping("/sysSession/movieCategory/{id}")
    public Object findMovieCategoryById(@PathVariable Long id){
        return new ResponseResult(200,"查询电影类别成功",sysSessionService.findMovieCategoryById(id));
    }

//    查询电影名
    @GetMapping("/sysSession/name/{id}")
    public Object findNameById(@PathVariable Long id){
        return new ResponseResult(200,"查询电影名字成功",sysSessionService.findNameById(id));
    }

//    更新电影票房
    @PostMapping("/sysSession/updateMovieSale")
    public Object updateMovieSale(@RequestBody UpdateMovieSaleVo updateMovieSaleVo){
        sysSessionService.updateMovieSale(updateMovieSaleVo);
        return new ResponseResult(200,"更新电影票房成功",null);
    }

//    更新电影评分以及影评人数
    @GetMapping("/sysSession/updateMovieRating")
    public Object updateMovieRating(){
        sysSessionService.updateMovieRating();
        return new ResponseResult(200,"更新电影评分成功",null);
    }
}
